package org.dizena.modules.master.web;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.dizena.common.pojo.PageReq;
import org.dizena.common.pojo.PageResp;
import org.dizena.common.pojo.master.UserVO;
import org.dizena.modules.master.bean.User;
import org.dizena.modules.master.service.UserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户-接口
 */
@RestController
@RequiresPermissions("master:user:*")
@RequestMapping("/api/v1/user")
public class ApiUserController
{
    @Resource
    private UserService service;

    /**
     * 用户-枚举
     */
    @PostMapping("list")
    public PageResp<User> list(PageReq req)
    {
        return service.list(req);
    }

    /**
     * 用户-新增
     */
    @PostMapping("add")
    public String add(@Validated UserVO vo)
    {
        return service.add(vo);
    }

    /**
     * 用户-删除
     */
    @PostMapping("del")
    public String del(String id)
    {
        return service.del(id);
    }

    /**
     * 用户-更新
     */
    @PostMapping("edit")
    public String edit(User user)
    {
        return service.edit(user);
    }

    /**
     * 用户-锁定
     */
    @PostMapping("lock")
    public String lock(String id)
    {
        return service.lockUser(id);
    }

    /**
     * 用户-明细
     */
    @PostMapping("get")
    public User get(String id)
    {
        return service.get(id);
    }


}
